class_name UpgradeCard
extends Panel

@export var item_data: ItemUpgrade: set = _set_data

@onready var icon: TextureRect = %Icon
@onready var name_label: Label = %NameLabel
@onready var description_label: Label = %DescriptionLabel

func _set_data(value: ItemUpgrade) -> void:
	item_data = value
	icon.texture = item_data.item_icon
	name_label.text = item_data.item_name
	description_label.text = item_data.description
	var style := Global.get_tier_style(item_data.item_tier)
	add_theme_stylebox_override("panel", style)


func _on_custom_button_pressed() -> void:
	if item_data and is_instance_valid(Global.player):
		item_data.apply_upgrade()
		SoundManager.player_sound(SoundManager.Sound.UI)
		Global.upgrade_selected()
